home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Sample Apps / CPlusSample / Sources / SampleLibrary.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  2.0 KB  |  72 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SampleLibrary.h
  3.  
  4.     Contains:    Interface for everything that the CPlusSampleLibrary exports including
  5.                 the TTrafficLight class.
  6.  
  7.     Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  8.  
  9. */
  10.  
  11.  
  12. #ifndef __SAMPLELIBRARY__
  13. #define __SAMPLELIBRARY__
  14.  
  15. #ifndef __TYPES__
  16. #include <Types.h>
  17. #endif
  18.  
  19. /*————————————————————————————————————————————————————————————————————————————————————
  20.     DEFINITIONS AND CONSTANTS
  21. ————————————————————————————————————————————————————————————————————————————————————*/
  22.  
  23. #define    rWindow                        128            /* application's window */
  24. #define rStopRect                    128            /* rectangle for Stop light */
  25. #define rGoRect                        129            /* rectangle for Go light */
  26.  
  27. #define    mLight                        131            /* Light menu */
  28. #define    iStop                        1
  29. #define    iGo                            2
  30.  
  31. // k<classname>ID needs to be declared, and is used as the classes class ID
  32. // when the shraed library is built
  33.  
  34. #define kTrafficLightLibID            "slm:samp$CPlusTrafficLightLib"
  35. #define kTTrafficLightID            "slm:samp$TTrafficLight,1.1"
  36.  
  37. #ifdef __cplusplus
  38.  
  39. class TTrafficLight;
  40.  
  41. /*————————————————————————————————————————————————————————————————————————————————————
  42.     class TTrafficLight
  43. ————————————————————————————————————————————————————————————————————————————————————*/
  44.  
  45. class TTrafficLight : public TDynamic {
  46.     public:
  47.                             TTrafficLight();
  48.         virtual                ~TTrafficLight();
  49.         
  50.         // public virtual methods
  51.         
  52.         virtual Boolean        IsValid() const;    // Override
  53.  
  54.         virtual Boolean        GetLightState() const;    // returns the state of the light
  55.         virtual void         SetLightState( Boolean state ); // set it to new state
  56.         virtual void        DrawLight();        // displays the light
  57.         virtual void        AdjustMenus( Boolean update );
  58.         virtual void        DoMenuCommand( short menuItem );
  59.  
  60.     protected:
  61.         static Boolean        GoGetRect( short rectID, Rect *theRect );
  62.  
  63.     private:                        
  64.         Boolean                fLightState;        // 0:indicates OFF, 1:indicates ON
  65.         Rect                fStopRect;            // rectangle for stop light
  66.         Rect                fGoRect;            // rectangle for go rectangle
  67.         WindowPtr            fWindow;            // objects grafport and window
  68. };
  69.  
  70. #endif
  71.  
  72. #endif